﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LS_WZJCXXWebForm.aspx.cs" Inherits="Anke.SHManage.Web.Reports.LS_WZJCXXWebForm" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>物资基础信息流水表</title>
    <script src="../Content/EasyUI/jquery.js"></script>
    <script src="../Content/EasyUI/jquery.easyui.js"></script>
    <script src="../Content/EasyUI/locale/easyui-lang-zh_CN.js"></script>
    <link href="../Content/EasyUI/themes/icon.css" rel="stylesheet" />
    <link href="../Content/EasyUI/themes/default/easyui.css" rel="stylesheet" />
    <script src="../Scripts/jquery.AnkeExtend.js"></script>
    <script type="text/javascript">

        $(document).ready(function () {
            initSearch();
            function initSearch() {
               
                //物资分类         
                var urlstr2 = "../IM/AllDictionary/GetMaterialTypeByUserInfo";
                $.EUIcomboboxTree("#MaterialType", {
                    url: urlstr2,//ajax后台取数据路径，返回的是json格式的数据
                    OneOption: [{
                        id: "",
                        text: "--请选择--",
                    }],
                    datainfo: {},
                    onSelect: function (rec) {
                        //if (rec.id == "") {
                        //    //$("#MaterialID").val("");
                        //    //$("#MaterialTypeInfo").val("");
                        //    //$("#Material").combobox("setText","");
                        //    return;
                        //}
                        var urlstr3 = "../IM/AllDictionary/GetMaterial?mType=" + rec.id;
                        //$("#MaterialTypeInfo").val(rec.id);
                        $("#Material").combogrid({
                            prompt: '--请选择--',
                            url: urlstr3,
                            panelWidth: 320,
                            idField: 'ID',
                            textField: 'Name',
                            groupField: 'QRCode',
                            columns: [[
                                { field: 'MCode', title: '代码', width: 50, align: 'right' },
                                { field: 'Name', title: '名称', width: 100 },
                                { field: 'UnitName', title: '单位', width: 50 },
                                { field: 'Specification', title: '规格', width: 50, align: 'right' },
                                { field: 'RealPrice', title: '售价', width: 50 },
                                { field: 'Unit', title: '单位', width: 50, sortable: false, hidden: true }
                            ]],
                            fitColumns: true,
                            filter: function (inputText, row) {
                                var opts = $(this).combogrid('options');
                                if (row[opts.groupField] == inputText) {
                                    return true;
                                } else if (row[opts.textField] == inputText) {
                                    return true;
                                } else {
                                    if (boolSearch) {
                                        boolSearch = false;
                                        searchBindMeterialbyName(urlstr3, inputText);
                                    }
                                }
                            },
                            onChange: function (n, o) {
                                if (n == "") {
                                    searchBindMeterialbyName(urlstr3, n);
                                    //$("#MaterialID").val("");
                                }
                            },
                            onSelect: function (rec) {
                                var g = $("#Material").combogrid("grid");	// 获取数据表格对象
                                var r = g.datagrid('getSelected');	// 获取选择的行
                                // $("#MaterialID").val($('#Material').combobox('getValue'));
                            }
                        });
                        searchBindMeterialbyName(urlstr3, "");

                    }

                });
                //物资名称 

                $.ajax({
                    type: 'POST',
                    url: "../IM/AllDictionary/GetMaterialTypeByUserInfoOther",
                    dataType: "json",
                    success: function (jsData) {
                        sss = jsData;
                        alert(sss);
                        var urlstr4 = "../IM/AllDictionary/GetMaterialLists?mType=" + sss;
                        $("#Material").combogrid({
                            prompt: '--请选择--',
                            url: urlstr4,
                            panelWidth: 320,
                            idField: 'ID',
                            textField: 'Name',
                            groupField: 'QRCode',
                            columns: [[
                                 { field: 'MCode', title: '代码', width: 50, align: 'right' },
                                 { field: 'Name', title: '名称', width: 100 },
                                 { field: 'UnitName', title: '单位', width: 50 },
                                 { field: 'Specification', title: '规格', width: 50, align: 'right' },
                                 { field: 'RealPrice', title: '售价', width: 50 },
                                 { field: 'Unit', title: '单位', width: 50, sortable: false, hidden: true }
                            ]],
                            fitColumns: true,
                            filter: function (inputText, row) {
                                var opts = $(this).combogrid('options');
                                if (row[opts.groupField] == inputText) {
                                    return true;
                                } else if (row[opts.textField] == inputText) {
                                    return true;
                                } else {
                                    if (boolSearch) {
                                        boolSearch = false;
                                        searchBindMeterialbyName(urlstr4, inputText);
                                    }
                                }
                            },
                            onChange: function (n, o) {
                                if (n == "") {
                                    searchBindMeterialbyName(urlstr4, n);
                                    //$("#Material").combobox('setValue',"");
                                }
                            },
                            onSelect: function (rec) {
                                var g = $("#Material").combogrid("grid");	// 获取数据表格对象
                                var r = g.datagrid('getSelected');	// 获取选择的行
                                //$('#Material').combobox('getValue');
                            }
                        });
                        searchBindMeterialbyName(urlstr4, "");
                    }

                });
                function searchBindMeterialbyName(urinfo, keyWord) {
                    $.ajax({
                        type: 'POST',
                        url: urinfo,
                        dataType: "json",
                        success: function (jsData) {
                            if (keyWord == "") {
                                $("#Material").combogrid("grid").datagrid("loadData", jsData);
                            } else {
                                for (var i = 0; i < jsData.length; i++) {
                                    if (jsData[i].Name.indexOf(keyWord) < 0) {
                                        if (jsData[i].MCode.indexOf(keyWord) < 0) {
                                            if (jsData[i].PinYin.indexOf(keyWord) < 0) {
                                                jsData.remove(jsData[i]);
                                                i--;
                                            }
                                        }
                                    }
                                }
                                $("#Material").combogrid("grid").datagrid("loadData", jsData);
                            }
                            boolSearch = true;
                        }
                    });
                }



            }
        })

    </script>

    <style type="text/css">
        .auto-style1 {
            height: 15px;
        }
      
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
            <div>
                <table>
                    <tr >
                        <td class="auto-style1">生产厂家：</td>
                        <td class="auto-style1">
                            <asp:TextBox ID="sccj" runat="server" class="easyui-textbox" Style="width: 160px"></asp:TextBox>

                        </td>
                        <td class="auto-style1">供应商：</td>
                        <td class="auto-style1">
                            <asp:TextBox ID="gys" runat="server" class="easyui-textbox" Style="width: 160px"></asp:TextBox>

                        </td>
                        <td class="auto-style1">是否有效：</td>
                        <td class="auto-style1">
                            <asp:DropDownList ID="ddl" runat="server">
                                <asp:ListItem Value="">全部</asp:ListItem>
                                <asp:ListItem Value="1">有效</asp:ListItem>
                                <asp:ListItem Value="0">无效</asp:ListItem>

                            </asp:DropDownList>
                            </td>
                    </tr>
                     
                    <tr>
                        <td class="auto-style1">分类：</td>
                        <td class="auto-style1">
                            <asp:TextBox ID="MaterialType" runat="server" class="easyui-combobox" Style="width: 160px"></asp:TextBox>

                        </td>
                        <td class="auto-style1">物资：</td>
                        <td class="auto-style1">
                            <asp:TextBox ID="Material" runat="server" class="easyui-combogrid" Style="width: 160px"></asp:TextBox>

                        </td>
                         <td></td><td></td>
                         <td class="auto-style1" >
                            <asp:Button ID="btnsearch" runat="server" Text="查询"  OnClick="btnsearch_click" />

                        </td>
                    </tr>
                  
                </table>
            </div>
            <div data-options="region:'center'" style="background: #fafafa; overflow: hidden">
                <table id="gridSurplusList"></table>
            </div>
            <div style="background-color: #fafafa; border-left: 1px solid scrollbar; overflow: hidden; height: 100%;">
                <rsweb:ReportViewer ID="ReportViewer1" runat="server" Width="100%" Height="100%"  SizeToReportContent="True">
                </rsweb:ReportViewer>
            </div>

        </div>
    </form>
</body>
</html>

